package com.study.spring_ai.tool;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.model.function.FunctionCallback;
import org.springframework.ai.model.function.FunctionCallingOptions;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.ai.ollama.api.OllamaApi;
import org.springframework.ai.tool.ToolCallback;
import org.springframework.ai.tool.function.FunctionToolCallback;
import org.springframework.ai.tool.metadata.ToolMetadata;
import org.springframework.ai.tool.method.MethodToolCallback;

/**
 * @author dejavu
 * @since 2025/7/21
 */
public class FunctionTools {

    public static void main(String[] args) {
        FunctionToolCallback.Builder<Void, Object> toolCallback = FunctionToolCallback.builder("", () -> {
                    return null;
                }).description("啥也没有")
                .inputSchema("返回空")
                .inputType(String.class)
//                .toolCallResultConverter()
                //配置当前工具输出是直接返回给程序还是返回给模型
                .toolMetadata(ToolMetadata.builder().returnDirect(true).build());


        ChatClient client = ChatClient.builder(OllamaChatModel.builder().ollamaApi(OllamaApi.builder().build()).build())
                .defaultTools(toolCallback).build();
        client.prompt()
                .options(FunctionCallingOptions.builder()
                        .withFunctionCallback((FunctionCallback) FunctionToolCallback.builder("你好",()->"hello").build()).build());
    }
}
